//
//  HDError.swift
//  Excited
//
//  Created by X140Yu on 6/14/16.
//  Copyright © 2016 X140Yu. All rights reserved.
//

import Foundation

enum HDError: String {
    case Success = "请求成功"
    case Failed = "请求失败"
    case MethodNotAllowed = "请求方式不允许"
    case ParameterError = "参数错误"
    case UsernameOrPasswordError = "用户名或密码错误"
    case ServerInternalError = "服务器内部错误"
    case TimeOut = "请求超时"
    case ConnectionError = "连接错误"
    case VerifyExpired = "验证过期"
    case NoData = "没有数据"
    case DefaultError = "发生了一些错误"
}

internal extension HDError {
    init(code: Int) {
        switch code {
        case 100: self = .Success
        case 101: self = .Failed
        case 102: self = .MethodNotAllowed
        case 103: self = .ParameterError
        case 104: self = .UsernameOrPasswordError
        case 105: self = .ServerInternalError
        case 106: self = .TimeOut
        case 107: self = .ConnectionError
        case 108: self = .VerifyExpired
        case 109: self = .NoData
        default: self = .DefaultError
        }
    }
}